#ifndef RENDERER_H
#define RENDERER_H

#include "Camera.h"
#include "TextureManager.h"
#include "terrain_Patch.h"

#include <d3d9.h>
#include <d3dx9.h>
#include <d3dx9core.h>

struct dxTerrainVertex {
	float x, y, z;		// Position
	float u1, v1;		// Alphamap coordinates
	float u2, v2;		// Texture coordinates
};

class Renderer
{
    public:
        Renderer();
        ~Renderer();

        void Init (HWND hWnd, int screenWidth, int screenHeight);
        void Destroy();

        void BeginScene();
        void EndScene();

        void RegisterCamera (Camera *camera);
        void UnregisterCamera ();

        void CameraTransformation(D3DXMATRIX viewMatrix);
        void PrepareSurface ();
        void DrawSurfacePatch (terrain::Patch *patch);

    private:

        void createRenderDevice (HWND hWnd, int screenWidth, int screenHeight);
        void setScreenMatrix(int screenWidth, int screenHeight);

        int m_ScreenWidth;
        int m_ScreenHeight;

        LPDIRECT3D9          m_D3D;
        LPDIRECT3DDEVICE9    m_Device;

        Camera *m_Camera;

        TextureManager m_TextureManager;

};

#endif // RENDERER_H
